package com.tengju.user.domain.model.login;

import lombok.AllArgsConstructor;

/**
 * @author wuziyang
 */
@AllArgsConstructor
public enum LoginType {

    /**
     * 验证码登陆
     */
    MOBILE_CODE_LOGIN(1,"验证码登陆","mobileCodeLoginService"),
    /**
     * 密码登陆
     */
    PWD_LOGIN(2,"密码登陆","pwdLoginService"),
    /**
     * 企业微信小程序登录
     */
    QY_WECHAT_MINI_PROGRAM_LOGIN(3,"企业微信小程序登录","qyMiniProgramLoginStrategyImpl"),

    ;

    private Integer val;
    private String desc;
    private String strategyName;

    public Integer getVal() {
        return val;
    }

    public String getDesc() {
        return desc;
    }

    public String getStrategyName() {
        return strategyName;
    }

    public static LoginType fromVal(Integer val) {
        for (LoginType type : values()) {
            if (type.val.equals(val)) {
                return type;
            }
        }
        return null;
    }


    public static LoginType fromName(String name) {
        for (LoginType type : values()) {
            if (type.name().equals(name)) {
                return type;
            }
        }
        return null;
    }
}
